package com.study.jdbc.wrapper;

import java.io.BufferedReader;
import java.io.IOException;

/**
* @Name: LineNumBufferReader
* @Description: 自定义带行号高效缓冲字符读取流：扩展BufferedReader包装类的功能
* 扩展：
* 	readLine()方法：为读取到的每行数据添加行号
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-2-18 上午11:57:52 
* @Version: V1.0
 */
public class LineNumBufferReader extends BufferedReader {
	
	private BufferedReader br ;
	//设置行号
	private int num = 1 ; 

	public LineNumBufferReader(BufferedReader br) {
		super(br);
		this.br = br ; 
	}
	
	@Override
	public String readLine() throws IOException {
		String data = br.readLine() ;
		if(data != null) {
			return (num ++) + ":" + data ;
		} 
		return null ;
	}

}
